#include <bits/stdc++.h>
using namespace std ;

    const int MAXN = 1e5 + 100 ;
    const int MAXL = 1e6 + 100 ;
    int T ;
    bool p[MAXL] ;
    bool fa[MAXN] ;

struct Node
{
    int d ;
    int vc , a ;

}ca[MAXN] ;

int main()
{
    freopen("detect.in" , "r" , stdin) ;
    freopen("detect.out" , "w" , stdout) ;

    ios::sync_with_stdio(0) ;
    cin.tie(0) ;
    cout.tie(0) ;

    cin >> T ;
    while ( T -- )
    {
        int ans1 = 0 , ans2 = 0 ;
        memset ( p , 0 , sizeof p ) ;
        int n , m , L , V ;
        cin >> n >> m >> L >> V ;
        for ( int i = 0 ; i < n ; i ++ )
        {
            cin >> ca[i].d >> ca[i].vc >> ca[i].a ;
        }
        for ( int i = 0 ; i < m ; i ++ )
        {
            int x ;
            cin >> x ;
            p[x] = 1 ;
        }
        int da = 0 ;
        for ( int i = 0 ; i < n ; i ++ )
        {
            da = min ( da , ca[i].d ) ;
            if ( ca[i].a == 0 )
            {
                if ( ca[i].vc > V ) fa[i] = 1 ;
            }

            else if ( ca[i].a > 0 )
            {
                long long cnt = ca[i].vc * ca[i].vc + 2 * ca[i].a * ( L - ca[i].d ) ;
                long long sum = V * V ;
                if ( cnt > sum ) fa[i] = 1 ;
            }
            else if ( ca[i].a < 0 )
            {
                for ( int j = ca[i].d ; j <= L ; j ++ )
                {
                    if ( p[j] == 1 )
                    {
                        long long cnt = ca[i].vc * ca[i].vc + 2 * ca[i].a * ( j - ca[i].d ) ;
                        long long sum = V * V ;
                        if ( cnt > sum ) fa[i] = 1 ;
                        break ;
                    }
                }
            }

        }
        for ( int i = 0 ; i < n ; i ++ )
        {
            if ( fa[i] == 1 )
            {
                ans1 ++ ;
                fa[i] = 0 ;
            }
        }
        cout << ans1 << " " ;
        bool ff = 0 ;
        for ( int i = da ; i <= L ; i ++ )
        {
            if ( p[i] == 1 )
            {
                cout << m - 1 << '\n' ;
                ff = 1 ;
                break ;
            }
        }
        if ( ff == 0 ) cout << m << '\n' ;
    }

    cout << endl ;

    return 0 ;
}

